﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Demos.DesignPatterns._22_状态模式
{
    /// <summary>
    /// 已处理状态
    /// </summary>
    public class ProcessedState:IOrderState
    {
        /// <summary>
        /// 订单处理
        /// </summary>
        /// <param name="order"></param>
        public void Process(Order order)
        {
            Console.WriteLine("订单已处理完成，请勿重复处理");
        }
        /// <summary>
        /// 订单发货
        /// </summary>
        /// <param name="order"></param>
        public void Ship(Order order)
        {
            Console.WriteLine("订单已发货");
            order.SetState(new ShippedState());
        }

        /// <summary>
        /// 订单配送
        /// </summary>
        /// <param name="order"></param>
        public void Deliver(Order order)
        {
            Console.WriteLine("错误：订单尚未发货，不能完成配送");
        }

        /// <summary>
        /// 订单取消
        /// </summary>
        /// <param name="order"></param>
        public void Cancel(Order order)
        {
            Console.WriteLine("订单已取消");
            order.SetState(new CancelledState());
        }

    }
}
